// pages/smartlife/bus_suzhou/station/station.js
var common = require('../../../../utils/common.js');
Page({
  data:{
    stationName:'',
    stationDetail:{
      "info": {
        long_info:"0米"
      }
    },
    options:null
  },
  onLoad:function(options){
    var that=this
    that.setData({
      stationName:options.name,
      options: options
    })
    that.onPullDownRefresh()
  },
  onPullDownRefresh: function () {
    this.getData()
  },
  getData:function () {
    var that = this
    // wx.showToast({
    //   title: '加载中',
    //   icon: 'loading',
    //   duration: 10000
    // })
    wx.getLocation({
      type: 'gcj02',
      success: function (res) {
        // var latitude = res.latitude
        // var longitude = res.longitude
        var lgtlat = common.gcj02tobd09(res.longitude, res.latitude)
        wx.request({
          url: common.trafficUrl() + 'busStationDetail',
          data: {
            city: 'suzhou',
            stationId: that.options.noteGuid,
            lat: lgtlat[1] + '',
            lgt: lgtlat[0] + ''
          },
          // header: {}, // 设置请求的 header
          success: function (res) {
            if (res.data.errorCode == 0) {
              that.setData({
                stationDetail: res.data.data
              })
            } else {

            }
            // wx.hideToast()
            wx.stopPullDownRefresh()
          }
        })
      }
    })
  },
	// guid='+that.data.searchList[index].Guid+'&lineName='+that.data.searchList[index].LName+'&lineDirection='+that.data.searchList[index].LDirection
  busItemClick:function(e){
    var that=this
    var index = e.currentTarget.dataset.index
    wx.navigateTo({
      url: '/pages/smartlife/bus_suzhou/busline/busline?guid='+that.data.stationDetail.list[index].Guid+'&lineName='+that.data.stationDetail.list[index].LName+'&lineDirection='+that.data.stationDetail.list[index].LDirection
    })
  },
  navClick:function(e){
	var that=this
	var latlgt = common.bd09togcj02(parseFloat(that.data.stationDetail.info.baidu_lng),parseFloat(that.data.stationDetail.info.baidu_lat))
	// console.log(latlgt)
	wx.openLocation({
      	latitude: latlgt[1],
      	longitude: latlgt[0],
      	name: that.data.stationName,
      	scale: 28
    })
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  }
})